package com.cluster.platform.controller;

import com.cluster.platform.common.api.CommonResult;
import com.cluster.platform.model.UmsFocusInfo;
import com.cluster.platform.service.UmsFocusInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: UmsFocusInfoController
 */
@Controller
@Api(tags = "UmsFocusInfoController", value = "关注功能接口")
@RequestMapping("/focus")
public class UmsFocusInfoController {

    @Autowired
    private UmsFocusInfoService umsFocusInfoService;

    /**
     * 新增关注
     */
    @ApiOperation("新增关注")
    @RequestMapping(value = "/addFocus", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> addFocus(UmsFocusInfo umsFocusInfo) {
        return umsFocusInfoService.addFocus(umsFocusInfo);
    }

    /**
     * 取消关注
     */
    @ApiOperation("取消关注")
    @RequestMapping(value = "/cancelFocus", method = RequestMethod.PUT)
    @ResponseBody
    public CommonResult<Object> cancelFocus(@RequestParam("id") String id) {
        return umsFocusInfoService.cancelFocus(id);
    }

    /**
     * 查询
     */
    @ApiOperation("查询")
    @RequestMapping(value = "/searchFocusList", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Object> searchFocusList(@RequestBody UmsFocusInfo umsFocusInfo) {
        return umsFocusInfoService.searchFocusList(umsFocusInfo);
    }

    /**
     * 分页查询
     */
    @ApiOperation("分页查询")
    @RequestMapping(value = "/searchFocusPage", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Object> searchFocusPage(UmsFocusInfo umsFocusInfo, Integer pageNum, Integer pageSize) {
        return umsFocusInfoService.searchFocusPage(umsFocusInfo, pageNum, pageSize);
    }

    /**
     * 关注人数
     */
    @ApiOperation("关注人数")
    @RequestMapping(value = "/focusNumber", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Object> focusNumber(@RequestParam("focusId") String focusId) {
        return CommonResult.success(umsFocusInfoService.searchFocusNumber(focusId));
    }

    /**
     * 被关注人数
     */
    @ApiOperation("被关注人数")
    @RequestMapping(value = "/beFocusNumber", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Object> beFocusNumber(@RequestParam("userId") String userId) {
        return CommonResult.success(umsFocusInfoService.searchBeFocusNumber(userId));
    }
}
